﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using TorchView.Composition;
using System.Windows.Input;
using TorchView.Windows;
using TorchView.SharedStashEditor.Models;
using TorchView.SharedStashEditor.Views;

namespace TorchView.SharedStashEditor.ViewModels
{
    public class AddItemViewModel : DependencyObject, IAddItemViewModel
    {
        public AddItemViewModel(IDialogView<IAddItemViewModel> view, ItemCollection collection)
        {
            View = view;
            view.Model = this;
            Items = collection;
            CancelCommand = new DirectCommand(o => { View.DialogResult = false; View.Close(); });
            OKCommand = new DirectCommand(o => { View.DialogResult = true; View.Close(); });
        }

        public static readonly DependencyProperty ItemIdProperty =
                DependencyProperty.Register("ItemId", typeof(long), typeof(AddItemViewModel), new UIPropertyMetadata((long)0));

        public IDialogView<IAddItemViewModel> View { get; private set; }
        public ICommand CancelCommand { get; private set; }
        public ICommand OKCommand { get; private set; }
        public ItemCollection Items { get; private set; }

        public long ItemId
        {
            get { return (long)GetValue(ItemIdProperty); }
            set { SetValue(ItemIdProperty, value); }
        }
    }
}
